<include file="Public:header" />
<include file="Public:leftside" />
<style>
.file-item {
    float: left;
    position: relative;
    margin: 0 20px 20px 0;
    padding: 4px;
    background: #000;
}
</style>
<div class="main-content">
	<div class="breadcrumbs breadcrumbs-fixed" id="breadcrumbs"> 
		<ul class="breadcrumb">
			<li> <i class="icon-home home-icon"></i> <a href="/">首页</a> </li>
			<li><a href="/Platform/ad">碎片管理</a></li>
			<li><a href="javascript:;">添加碎片</a></li>
			
		</ul>
	</div>
	<section class="scrollable wrapper">
			<div class="row padder-v">
				<div class="col-sm-9">
					<a href="/Platform/ad.html" class="btn btn-sm btn-default"> 碎片管理 </a>
					<a href="/Platform/ad_add.html" class="btn btn-sm btn-primary"><i class="fa fa-plus"></i> 添加碎片 </a>
				</div>

			</div>
			<!-- 操作提示  start -->
			<section class="panel-default m-b-sm">
				<div class="alert alert-info">
					<p>
						<button type="button" class="close"><i class="fa fa-minus"></i></button>
						<i class="fa fa-hand-o-right m-r-xs"></i><strong>操作提示</strong>
					</p>
					<p class="alert-p m-l-xl"><i class="fa fa-caret-right m-r-xs"></i>编辑/添加碎片</p>
				</div>
			</section>
			
			<!-- 操作提示  end -->
	</section>
	<div class="page-content">
		<form action="/Platform/ad_add/" method="post" class="form form-horizontal" role="form">
            <input type="hidden" name="ad_id" value="<?PHP echo $ad['ad_id'];?>" />
			<div class="form-group">
				<label class="col-sm-3 control-label no-padding-right" for="form-field-1">碎片名称</label>
				<div class="col-sm-9">
					<input type="text" id="form-field-1" datatype="required" data="栏目名称" placeholder="栏目名称" name="ad_name" value="<?=$ad['ad_name']?>" class="col-xs-10 col-sm-5" />
				</div>
			</div>
			<div class="space-4"></div>
			<div class="form-group">
				<label class="col-sm-3 control-label no-padding-right" for="form-field-1">碎片代码</label>
				<div class="col-sm-9">
					<textarea name="ad_content" rows="5" cols="57"><?=$ad['ad_content']?></textarea>
				</div>
			</div>
			<div class="space-4"></div>
			<div class="form-group">
				<label class="col-sm-3 control-label no-padding-right" for="form-field-1">图片地址生成</label>
				<div class="col-sm-9" style="line-height: 28px;">
					<input type="text" id="img_id"  placeholder="图片地址"  value="<?=$menuCurrent['name']?>" class="col-xs-10 col-sm-5" />
					注：请把上传“图片地址”复制到“碎片代码”中所需替换的地方
				</div>
			</div>
			<div class="space-4"></div>
			<div class="form-group">
				<label class="col-sm-3 control-label no-padding-right" for="form-input-readonly">图片上传</label>
	
				<div class="col-sm-9">
					<div id="uploader" style="width:200px;overflow:hidden">
                      <div id="fileList" class="uploader-list">
                      <div id="WU_FILE_0" class="file-item thumbnail upload-state-done"><img class="img-responsive" src=""></div>
                      <input type="hidden" name="UpFilePathInfo" value="">
                     
                      </div>
                      <div id="cfilePicker">选择图片</div>
                  	</div>
				</div>
			</div>
	
			<div class="clearfix form-actions">
				<div class="col-md-offset-3 col-md-9">
					<button class="btn btn-info formSubmit" id="form" type="button"><i class="icon-ok bigger-110"></i>提交</button>
					&nbsp; &nbsp; &nbsp;
					<button class="btn" type="button" onclick="history.back(-1);"><i class="icon-undo bigger-110"></i>返回</button>
				</div>
			</div>
			
        </form>
    </div>


<script>
//全局变量
    var GV = {
         DIMAUB: "/",
        JS_ROOT: "NewAdmin/js/",
        TOKEN: ""
    };
</script>
<script type="text/javascript" src="/NewAdmin/js/webuploader/webuploader.js"></script>
<script type="text/javascript" src="/NewAdmin/js/webuploader/getting-started.js"></script>
<link rel="stylesheet" href="/NewAdmin/css/webuploader.css" />
<script src="/NewAdmin/js/wind.js"></script>
<link href="/NewAdmin/js/artDialog/skins/default.css" rel="stylesheet" />
<script src="/NewAdmin/js/zhlmy.js"></script>
<script type="text/javascript">
var BASE_URL = '/NewAdmin/js/webuploader/';
var UPLOAD_SERVER='{:U("User/uploadify_wb")}';
var UpFilePathInfo='<?=$menuCurrent['UpFilePathInfo']?>';
$(function() {
	$('#uploader img').attr('src',UpFilePathInfo);
	$(':input[name="UpFilePathInfo"]').val(UpFilePathInfo);
	$("#uploader").setUploader(null,{uploadImgType:'normal',thumb:{height:102}});
	setInterval("changeimg()",1000);
});
function changeimg(){
	var src=$(':input[name="UpFilePathInfo"]').val();
	var sc_src=$('#img_id').val();
	if(sc_src==''){
		$('#img_id').val(src);
	}
	
}
</script>
<script>
$(function () {
    // 为每一个textarea绑定事件使其高度自适应
    $.each($("textarea"), function(i, n){
        autoTextarea($(n)[0]);
    });
})
/**
 * 文本框根据输入内容自适应高度
 * {HTMLElement}   输入框元素
 * {Number}        设置光标与输入框保持的距离(默认0)
 * {Number}        设置最大高度(可选)
 */
var autoTextarea = function (elem, extra, maxHeight) {
    extra = extra || 0;
    var isFirefox = !!document.getBoxObjectFor || 'mozInnerScreenX' in window,
    isOpera = !!window.opera && !!window.opera.toString().indexOf('Opera'),
        addEvent = function (type, callback) {
            elem.addEventListener ?
                elem.addEventListener(type, callback, false) :
                elem.attachEvent('on' + type, callback);
        },
        getStyle = elem.currentStyle ? 
        function (name) {
            var val = elem.currentStyle[name];
            if (name === 'height' && val.search(/px/i) !== 1) {
                var rect = elem.getBoundingClientRect();
                return rect.bottom - rect.top -
                       parseFloat(getStyle('paddingTop')) -
                       parseFloat(getStyle('paddingBottom')) + 'px';       
            };
            return val;
        } : function (name) {
            return getComputedStyle(elem, null)[name];
        },
    minHeight = parseFloat(getStyle('height'));
    elem.style.resize = 'both';//如果不希望使用者可以自由的伸展textarea的高宽可以设置其他值

    var change = function () {
        var scrollTop, height,
            padding = 0,
            style = elem.style;

        if (elem._length === elem.value.length) return;
        elem._length = elem.value.length;

        if (!isFirefox && !isOpera) {
            padding = parseInt(getStyle('paddingTop')) + parseInt(getStyle('paddingBottom'));
        };
        scrollTop = document.body.scrollTop || document.documentElement.scrollTop;

        elem.style.height = minHeight + 'px';
        if (elem.scrollHeight > minHeight) {
            if (maxHeight && elem.scrollHeight > maxHeight) {
                height = maxHeight - padding;
                style.overflowY = 'auto';
            } else {
                height = elem.scrollHeight - padding;
                style.overflowY = 'hidden';
            };
            style.height = height + extra + 'px';
            scrollTop += parseInt(style.height) - elem.currHeight;
            document.body.scrollTop = scrollTop;
            document.documentElement.scrollTop = scrollTop;
            elem.currHeight = parseInt(style.height);
        };
    };

    addEvent('propertychange', change);
    addEvent('input', change);
    addEvent('focus', change);
    change();
};
</script>
<include file="Public:footer" />